﻿// --------------------------------------------------------------------------------------------------------------------
// <copyright file="LocalizedEmailAttribute.shared.cs" company="Spenta Consulting">
//   (c) Copyright 2011
// </copyright>
// <summary>
//   Defines the a custom attribute to validate email addresses
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Spenta.StreetCare.Core.Shared.Attributes
{
    using System.ComponentModel.DataAnnotations;

    /// <summary>
    /// Defines the a custom attribute to validate email addresses
    /// </summary>
    public class LocalizedEmailAttribute : RegularExpressionAttribute
    {
        /// <summary>
        /// Initializes a new instance of the <see cref="LocalizedEmailAttribute"/> class.
        /// </summary>
        public LocalizedEmailAttribute()
            : base("^[a-z0-9_\\+-]+(\\.[a-z0-9_\\+-]+)*@[a-z0-9-]+(\\.[a-z0-9-]+)*\\.([a-z]{2,4})$")
        {
            ErrorMessageResourceName = "Email_ValidationError";
            ErrorMessageResourceType = typeof(Silverlight.Resources.Spenta_StreetCare_Core);
        }
    }
}